package com.ruoyi.lxy.zust.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.lxy.zust.domain.TDepartment;
import com.ruoyi.lxy.zust.domain.vo.TDepartmentVo;
import com.ruoyi.lxy.zust.mapper.DepartmentMapper;
import com.ruoyi.lxy.zust.service.IDepartmentServiceI;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@DS("slave")
@RequiredArgsConstructor
@Service
public class IDepartmentServiceImpl implements IDepartmentServiceI {
    final DepartmentMapper departmentMapper;
    @Override
    public TableDataInfo<TDepartmentVo> getDepartmentList() {
        List<TDepartmentVo> vos=new ArrayList<>();
        List<TDepartment> departments=departmentMapper.allDepartment();
        for(TDepartment t:departments){
            TDepartmentVo vo=new TDepartmentVo();
            BeanUtils.copyProperties(t,vo);
            vos.add(vo);
        }
        return TableDataInfo.build(vos);
    }
}
